package com.zdxlz.fcmp.upms.api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zdxlz.fcmp.upms.api.entity.SystemUserRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户角色关联表(SystemUserRole)表数据库访问层
 *
 * @author makejava
 * @since 2025-02-24 14:30:47
 */
@Mapper
public interface SystemUserRoleMapper extends BaseMapper<SystemUserRole> {

    @Select("""
            SELECT distinct sr.name
               FROM system_role sr
                        left join system_user_role sur on sr.id = sur.role_id and sr.status = true
               where sur.user_id = #{userId}
            """)
    List<String> getUserRoleByUserId(@Param("userId") Integer userId);
}
